/*-------------------------------------------------------------------------
 *
 * tablesample.c
 *		  TABLESAMPLE 特性的支持函数
 *
 * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 *
 * IDENTIFICATION
 *		  src/backend/access/tablesample/tablesample.c
 *
 * -------------------------------------------------------------------------
 */

#include "postgres.h"

#include "access/tsmapi.h"


/*
 * GetTsmRoutine --- 通过调用处理程序获取 TsmRoutine 结构。
 *
 * 这是一个便利例程，旨在检查错误。
 */
TsmRoutine *
GetTsmRoutine(Oid fc_tsmhandler)
{
	Datum		fc_datum;
	TsmRoutine *fc_routine;

	fc_datum = OidFunctionCall1(fc_tsmhandler, PointerGetDatum(NULL));
	fc_routine = (TsmRoutine *) DatumGetPointer(fc_datum);

	if (fc_routine == NULL || !IsA(fc_routine, TsmRoutine))
		elog(ERROR, "tablesample handler function %u did not return a TsmRoutine struct",
			 fc_tsmhandler);

	return fc_routine;
}
